<?php require './view/public/header.php'; ?>
    <!--/sidebar-->
    <div class="main-wrap">
        <div class="search-wrap">
            <div class="search-content">
                <form action="./index.php?c=user&a=index">
                    <table class="search-tab">
                        <tr>
                            <th width="120">选择分类:</th>
                            <td>
                                <select name="auth" id="">
                                    <option value="">全部</option>
                                    <option <?php if(isset($_GET['auth']) && ($_GET['auth']=='0')) echo 'selected'; ?> value="0">会员</option>
									<option <?php if(isset($_GET['auth']) && ($_GET['auth']=='1')) echo 'selected'; ?> value="1">管理员</option>
                                </select>
                            </td>
                            <th width="70">关键字:</th>
                            <td><input class="common-text" placeholder="名字" name="uname" value="<?php if(isset($_GET['uname'])) echo $_GET['uname']; ?>" id="" type="text"></td>
                            <td><input class="btn btn-primary btn2" value="查询" type="submit"></td>
                        </tr>
                    </table>
                </form>
            </div>
        </div>
        <div class="result-wrap">
            <form name="myform" id="myform" method="post">
                <div class="result-content">
                    <table class="result-tab" width="100%">
                        <tr>
                            <th>用户ID</th>
                            <th>用户名</th>
                            <th>性别</th>
                            <th>头像</th>
                            <th>生日</th>
                            <th>电话</th>
                            <th>地址</th>
                            <th>权限</th>
                            <th>邮箱</th>
                            <th>注册时间</th>
                            <th>操作</th>
                        </tr>
						<?php
							if(!isset($_GET['uname'])){
								$_GET['uname']='';
								$_GET['auth']='';
							}
							if(!$ret)die;
							$sex = ['m'=>'男','w'=>'女','x'=>'保密'];
							$auth = ['会员','管理员'];
							foreach($ret as $v){
								echo '<tr>';
									echo '<td>'.$v['uid'].'</td>';
									echo '<td>'.$v['uname'].'</td>';
									echo '<td>'.$sex[$v['sex']].'</td>';
									echo '<td><img src="'.PIC_PATH.'sm_'.$v['uface'].'"></td>';
									if($v['birth']=='0'){
										echo '<td> </td>';
									}else{
										echo '<td>'.date('Y-m-d',$v['birth']).'</td>';
									}
									echo '<td>'.$v['tel'].'</td>';
									echo '<td>'.$v['addr'].'</td>';
									if($v['auth']==0){
										echo '<td style="color:red">'.$auth[$v['auth']].'</td>';
									}elseif($v['auth']==1){
										echo '<td style="color:green">'.$auth[$v['auth']].'</td>';
									}
								
									echo '<td>'.$v['email'].'</td>';
									echo '<td>'.date('Y-m-d',$v['regtime']).'</td>';
									echo '<td>';
									echo " <a class='link-update' href='./index.php?c=user&a=change&id=$v[uid]&nowPage=$nowPage&auth=$_GET[auth]&uname=$_GET[uname]'>修改</a>";
									echo " <a onclick=\"return confirm('确定要删除吗?')\" class='link-del' href='./index.php?c=user&a=del&pic=$v[uface]&id=$v[uid]&nowPage=$nowPage&auth=$_GET[auth]&uname=$_GET[uname]'>删除</a>";
									if($v['auth']==0){
										echo " <a style='color:green' class='link-update' href='./index.php?c=user&a=auth&id=$v[uid]&nowPage=$nowPage&s=1&uname=$_GET[uname]&auth=$_GET[auth]'>设为管理员</a>";
									}elseif($v['auth']==1){
										echo " <a style='color:red' class='link-update' href='./index.php?c=user&a=auth&id=$v[uid]&nowPage=$nowPage&s=0&uname=$_GET[uname]&auth=$_GET[auth]'>取消管理员</a>";
									}
									echo '</td>';
								echo '</tr>';
							}
						?>
                    </table>
                    <div class="list-page">
						<?php
							echo "<a href='./index.php?c=user&a=index&nowPage=1&auth=$_GET[auth]&uname=$_GET[uname]'>首页</a>";
							echo "<a href='./index.php?c=user&a=index&nowPage=$prevPage&auth=$_GET[auth]&uname=$_GET[uname]'>上一页</a>";
							echo " &nbsp; $allRows 条 $nowPage/$allPage 页 &nbsp; ";
							echo "<a href='./index.php?c=user&a=index&nowPage=$nextPage&auth=$_GET[auth]&uname=$_GET[uname]'>下一页</a>";
							echo "<a href='./index.php?c=user&a=index&nowPage=$allPage&auth=$_GET[auth]&uname=$_GET[uname]'>尾页</a>";
						?>
					</div>
                </div>
            </form>
        </div>
    </div>
    <!--/main-->
<?php require './view/public/footer.php'; ?>